home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / PInterfaces / Components.p < prev    next >
Encoding:
Text File  |  1994-11-11  |  11.0 KB  |  323 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        Components.p
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT Components;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __COMPONENTS__}
  27. {$SETC __COMPONENTS__ := 1}
  28.  
  29. {$I+}
  30. {$SETC ComponentsIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {    ConditionalMacros.p                                            }
  38.  
  39. {$IFC UNDEFINED __MIXEDMODE__}
  40. {$I MixedMode.p}
  41. {$ENDC}
  42.  
  43. {$PUSH}
  44. {$ALIGN MAC68K}
  45. {$LibExport+}
  46.  
  47. CONST
  48.     kAppleManufacturer            = 'appl';                        { Apple supplied components }
  49.     kComponentResourceType        = 'thng';
  50.  
  51.     kAnyComponentType            = 0;
  52.     kAnyComponentSubType        = 0;
  53.     kAnyComponentManufacturer    = 0;
  54.     kAnyComponentFlagsMask        = 0;
  55.  
  56.     cmpWantsRegisterMessage        = 1 * (2**(31));
  57.  
  58.     kComponentOpenSelect        = -1;                            { ComponentInstance for this open }
  59.     kComponentCloseSelect        = -2;                            { ComponentInstance for this close }
  60.     kComponentCanDoSelect        = -3;                            { selector # being queried }
  61.     kComponentVersionSelect        = -4;                            { no params }
  62.     kComponentRegisterSelect    = -5;                            { no params }
  63.     kComponentTargetSelect        = -6;                            { ComponentInstance for top of call chain }
  64.     kComponentUnregisterSelect    = -7;                            { no params }
  65.  
  66. { Component Resource Extension flags }
  67.     componentDoAutoVersion        = 0+(1 * (2**(0)));
  68.     componentWantsUnregister    = 0+(1 * (2**(1)));
  69.     componentAutoVersionIncludeFlags = 0+(1 * (2**(2)));
  70.     componentHasMultiplePlatforms = 0+(1 * (2**(3)));
  71.  
  72. { Set Default Component flags }
  73.     defaultComponentIdentical    = 0;
  74.     defaultComponentAnyFlags    = 1;
  75.     defaultComponentAnyManufacturer = 2;
  76.     defaultComponentAnySubType    = 4;
  77.     defaultComponentAnyFlagsAnyManufacturer = 0+(defaultComponentAnyFlags + defaultComponentAnyManufacturer);
  78.     defaultComponentAnyFlagsAnyManufacturerAnySubType = 0+(defaultComponentAnyFlags + defaultComponentAnyManufacturer + defaultComponentAnySubType);
  79.  
  80. { RegisterComponentResource flags }
  81.     registerComponentGlobal        = 1;
  82.     registerComponentNoDuplicates = 2;
  83.     registerComponentAfterExisting = 4;
  84.  
  85.  
  86. TYPE
  87.     ComponentDescription = RECORD
  88.         componentType:            OSType;                                    { A unique 4-byte code indentifying the command set }
  89.         componentSubType:        OSType;                                    { Particular flavor of this instance }
  90.         componentManufacturer:    OSType;                                    { Vendor indentification }
  91.         componentFlags:            LONGINT;                                { 8 each for Component,Type,SubType,Manuf/revision }
  92.         componentFlagsMask:        LONGINT;                                { Mask for specifying which flags to consider in search, zero during registration }
  93.     END;
  94.     ResourceSpec = RECORD
  95.         resType:                OSType;                                    { 4-byte code  }
  96.         resID:                    INTEGER;
  97.     END;
  98.     ComponentResource = RECORD
  99.         cd:                        ComponentDescription;                    { Registration parameters }
  100.         component:                ResourceSpec;                            { resource where Component code is found }
  101.         componentName:            ResourceSpec;                            { name string resource }
  102.         componentInfo:            ResourceSpec;                            { info string resource }
  103.         componentIcon:            ResourceSpec;                            { icon resource }
  104.     END;
  105.     ComponentResourcePtr = ^ComponentResource;
  106.     ComponentResourceHandle = ^ComponentResourcePtr;
  107.  
  108.     ComponentPlatformInfo = RECORD
  109.         componentFlags:            LONGINT;                                { flags of Component }
  110.         component:                ResourceSpec;                            { resource where Component code is found }
  111.         platformType:            INTEGER;                                { gestaltSysArchitecture result }
  112.     END;
  113.     ComponentResourceExtension = RECORD
  114.         componentVersion:        LONGINT;                                { version of Component }
  115.         componentRegisterFlags:    LONGINT;                                { flags for registration }
  116.         componentIconFamily:    INTEGER;                                { resource id of Icon Family }
  117.     END;
  118.     ComponentPlatformInfoArray = RECORD
  119.         count:                    LONGINT;
  120.         platformArray:            ARRAY [0..0] OF ComponentPlatformInfo;
  121.     END;
  122.     ExtComponentResource = RECORD
  123.         cd:                        ComponentDescription;                    { registration parameters }
  124.         component:                ResourceSpec;                            { resource where Component code is found }
  125.         componentName:            ResourceSpec;                            { name string resource }
  126.         componentInfo:            ResourceSpec;                            { info string resource }
  127.         componentIcon:            ResourceSpec;                            { icon resource }
  128.         componentVersion:        LONGINT;                                { version of Component }
  129.         componentRegisterFlags:    LONGINT;                                { flags for registration }
  130.         componentIconFamily:    INTEGER;                                { resource id of Icon Family }
  131.         count:                    LONGINT;                                { elements in platformArray }
  132.         platformArray:            ARRAY [0..0] OF ComponentPlatformInfo;
  133.     END;
  134.     ComponentParameters = PACKED RECORD
  135.         flags:                    CHAR;                                    { call modifiers: sync/async, deferred, immed, etc }
  136.         paramSize:                CHAR;                                    { size in bytes of actual parameters passed to this call }
  137.         what:                    INTEGER;                                { routine selector, negative for Component management calls }
  138.         params:                    ARRAY [0..0] OF LONGINT;                { actual parameters for the indicated routine }
  139.     END;
  140.     ComponentRecord = RECORD
  141.         data:                    ARRAY [0..0] OF LONGINT;
  142.     END;
  143.     Component = ^ComponentRecord;
  144.  
  145.     ComponentInstanceRecord = RECORD
  146.         data:                    ARRAY [0..0] OF LONGINT;
  147.     END;
  148.     ComponentInstance = ^ComponentInstanceRecord;
  149.  
  150.     ComponentResult = LONGINT;
  151.  
  152.     ComponentRoutineProcPtr = ProcPtr;  { FUNCTION ComponentRoutine(VAR cp: ComponentParameters; componentStorage: Handle): ComponentResult; }
  153.     ComponentRoutineUPP = UniversalProcPtr;
  154.  
  155. CONST
  156.     uppComponentRoutineProcInfo = $000003F0; { FUNCTION (4 byte param, 4 byte param): 4 byte result; }
  157.  
  158. FUNCTION NewComponentRoutineProc(userRoutine: ComponentRoutineProcPtr): ComponentRoutineUPP;
  159.     {$IFC NOT GENERATINGCFM }
  160.     INLINE $2E9F;
  161.     {$ENDC}
  162.  
  163. FUNCTION CallComponentRoutineProc(VAR cp: ComponentParameters; componentStorage: Handle; userRoutine: ComponentRoutineUPP): ComponentResult;
  164.     {$IFC NOT GENERATINGCFM}
  165.     INLINE $205F, $4E90;
  166.     {$ENDC}
  167.     
  168. TYPE
  169.     ComponentRoutine = ComponentRoutineUPP;
  170.  
  171. {
  172.     The parameter list for each ComponentFunction is unique. It is 
  173.     therefore up to users to create the appropriate procInfo for their 
  174.     own ComponentFunctions where necessary.
  175. }
  176.     ComponentFunctionUPP = UniversalProcPtr;
  177.  
  178.  
  179. FUNCTION RegisterComponent(VAR cd: ComponentDescription; componentEntryPoint: ComponentRoutineUPP; global: INTEGER; componentName: Handle; componentInfo: Handle; componentIcon: Handle): Component;
  180.     {$IFC NOT GENERATINGCFM}
  181.     INLINE $7001, $A82A;
  182.     {$ENDC}
  183. FUNCTION RegisterComponentResource(tr: ComponentResourceHandle; global: INTEGER): Component;
  184.     {$IFC NOT GENERATINGCFM}
  185.     INLINE $7012, $A82A;
  186.     {$ENDC}
  187. FUNCTION UnregisterComponent(aComponent: Component): OSErr;
  188.     {$IFC NOT GENERATINGCFM}
  189.     INLINE $7002, $A82A;
  190.     {$ENDC}
  191. FUNCTION FindNextComponent(aComponent: Component; VAR looking: ComponentDescription): Component;
  192.     {$IFC NOT GENERATINGCFM}
  193.     INLINE $7004, $A82A;
  194.     {$ENDC}
  195. FUNCTION CountComponents(VAR looking: ComponentDescription): LONGINT;
  196.     {$IFC NOT GENERATINGCFM}
  197.     INLINE $7003, $A82A;
  198.     {$ENDC}
  199. FUNCTION GetComponentInfo(aComponent: Component; VAR cd: ComponentDescription; componentName: Handle; componentInfo: Handle; componentIcon: Handle): OSErr;
  200.     {$IFC NOT GENERATINGCFM}
  201.     INLINE $7005, $A82A;
  202.     {$ENDC}
  203. FUNCTION GetComponentListModSeed: LONGINT;
  204.     {$IFC NOT GENERATINGCFM}
  205.     INLINE $7006, $A82A;
  206.     {$ENDC}
  207. { Component Instance Allocation and dispatch routines }
  208. FUNCTION OpenComponent(aComponent: Component): ComponentInstance;
  209.     {$IFC NOT GENERATINGCFM}
  210.     INLINE $7007, $A82A;
  211.     {$ENDC}
  212. FUNCTION CloseComponent(aComponentInstance: ComponentInstance): OSErr;
  213.     {$IFC NOT GENERATINGCFM}
  214.     INLINE $7008, $A82A;
  215.     {$ENDC}
  216. FUNCTION GetComponentInstanceError(aComponentInstance: ComponentInstance): OSErr;
  217.     {$IFC NOT GENERATINGCFM}
  218.     INLINE $700A, $A82A;
  219.     {$ENDC}
  220. { Direct calls to the Components }
  221. FUNCTION ComponentFunctionImplemented(ci: ComponentInstance; ftnNumber: INTEGER): LONGINT;
  222.     {$IFC NOT GENERATINGCFM}
  223.     INLINE $2F3C, $2, $FFFD, $7000, $A82A;
  224.     {$ENDC}
  225. FUNCTION GetComponentVersion(ci: ComponentInstance): LONGINT;
  226.     {$IFC NOT GENERATINGCFM}
  227.     INLINE $2F3C, $0, $FFFC, $7000, $A82A;
  228.     {$ENDC}
  229. FUNCTION ComponentSetTarget(ci: ComponentInstance; target: ComponentInstance): LONGINT;
  230.     {$IFC NOT GENERATINGCFM}
  231.     INLINE $2F3C, $4, $FFFA, $7000, $A82A;
  232.     {$ENDC}
  233. { Component Management routines }
  234. PROCEDURE SetComponentInstanceError(aComponentInstance: ComponentInstance; theError: OSErr);
  235.     {$IFC NOT GENERATINGCFM}
  236.     INLINE $700B, $A82A;
  237.     {$ENDC}
  238. FUNCTION GetComponentRefcon(aComponent: Component): LONGINT;
  239.     {$IFC NOT GENERATINGCFM}
  240.     INLINE $7010, $A82A;
  241.     {$ENDC}
  242. PROCEDURE SetComponentRefcon(aComponent: Component; theRefcon: LONGINT);
  243.     {$IFC NOT GENERATINGCFM}
  244.     INLINE $7011, $A82A;
  245.     {$ENDC}
  246. FUNCTION OpenComponentResFile(aComponent: Component): INTEGER;
  247.     {$IFC NOT GENERATINGCFM}
  248.     INLINE $7015, $A82A;
  249.     {$ENDC}
  250. FUNCTION CloseComponentResFile(refnum: INTEGER): OSErr;
  251.     {$IFC NOT GENERATINGCFM}
  252.     INLINE $7018, $A82A;
  253.     {$ENDC}
  254. { Component Instance Management routines }
  255. FUNCTION GetComponentInstanceStorage(aComponentInstance: ComponentInstance): Handle;
  256.     {$IFC NOT GENERATINGCFM}
  257.     INLINE $700C, $A82A;
  258.     {$ENDC}
  259. PROCEDURE SetComponentInstanceStorage(aComponentInstance: ComponentInstance; theStorage: Handle);
  260.     {$IFC NOT GENERATINGCFM}
  261.     INLINE $700D, $A82A;
  262.     {$ENDC}
  263. FUNCTION GetComponentInstanceA5(aComponentInstance: ComponentInstance): LONGINT;
  264.     {$IFC NOT GENERATINGCFM}
  265.     INLINE $700E, $A82A;
  266.     {$ENDC}
  267. PROCEDURE SetComponentInstanceA5(aComponentInstance: ComponentInstance; theA5: LONGINT);
  268.     {$IFC NOT GENERATINGCFM}
  269.     INLINE $700F, $A82A;
  270.     {$ENDC}
  271. FUNCTION CountComponentInstances(aComponent: Component): LONGINT;
  272.     {$IFC NOT GENERATINGCFM}
  273.     INLINE $7013, $A82A;
  274.     {$ENDC}
  275. { Useful helper routines for convenient method dispatching }
  276. FUNCTION CallComponentFunction(VAR params: ComponentParameters; func: ComponentFunctionUPP): LONGINT;
  277.     {$IFC NOT GENERATINGCFM}
  278.     INLINE $70FF, $A82A;
  279.     {$ENDC}
  280. FUNCTION CallComponentFunctionWithStorage(storage: Handle; VAR params: ComponentParameters; func: ComponentFunctionUPP): LONGINT;
  281.     {$IFC NOT GENERATINGCFM}
  282.     INLINE $70FF, $A82A;
  283.     {$ENDC}
  284. FUNCTION DelegateComponentCall(VAR originalParams: ComponentParameters; ci: ComponentInstance): LONGINT;
  285.     {$IFC NOT GENERATINGCFM}
  286.     INLINE $7024, $A82A;
  287.     {$ENDC}
  288. FUNCTION SetDefaultComponent(aComponent: Component; flags: INTEGER): OSErr;
  289.     {$IFC NOT GENERATINGCFM}
  290.     INLINE $701E, $A82A;
  291.     {$ENDC}
  292. FUNCTION OpenDefaultComponent(componentType: OSType; componentSubType: OSType): ComponentInstance;
  293.     {$IFC NOT GENERATINGCFM}
  294.     INLINE $7021, $A82A;
  295.     {$ENDC}
  296. FUNCTION CaptureComponent(capturedComponent: Component; capturingComponent: Component): Component;
  297.     {$IFC NOT GENERATINGCFM}
  298.     INLINE $701C, $A82A;
  299.     {$ENDC}
  300. FUNCTION UncaptureComponent(aComponent: Component): OSErr;
  301.     {$IFC NOT GENERATINGCFM}
  302.     INLINE $701D, $A82A;
  303.     {$ENDC}
  304. FUNCTION RegisterComponentResourceFile(resRefNum: INTEGER; global: INTEGER): LONGINT;
  305.     {$IFC NOT GENERATINGCFM}
  306.     INLINE $7014, $A82A;
  307.     {$ENDC}
  308. FUNCTION GetComponentIconSuite(aComponent: Component; VAR iconSuite: Handle): OSErr;
  309.     {$IFC NOT GENERATINGCFM}
  310.     INLINE $7029, $A82A;
  311.     {$ENDC}
  312.  
  313. {$ALIGN RESET}
  314. {$POP}
  315.  
  316. {$SETC UsingIncludes := ComponentsIncludes}
  317.  
  318. {$ENDC} {__COMPONENTS__}
  319.  
  320. {$IFC NOT UsingIncludes}
  321.  END.
  322. {$ENDC}
  323.